Skip to content

Keep private persistence and certification output owner-only - #3

Draft
pjeweb wants to merge 3 commits into
mainfrom
osb/pr/private-file-permissions
Draft

pjeweb wants to merge 3 commits into
mainfrom
osb/pr/private-file-permissions

Conversation

@pjeweb

@pjeweb pjeweb commented Nov 14, 2026 •

Copy link
Copy Markdown

Why

The modem stack's private files (its change journal, policies and data-usage records) can briefly expose their contents while a temporary file is being written, and saving ownership metadata leaves an existing readable lock file readable. Bun can ignore the requested file mode, and Node only applies it when it creates a file, so "owner-only" isn't actually guaranteed. A stale temporary symlink can also redirect a policy write into another file.

What

  • Journal, policy and usage files are made owner-only before any contents are written.
  • Policy files are replaced through fresh, exclusively created temporary files, and old temporary files are cleaned up on save without following symlinks.
  • Symlinks and other non-regular files are refused without blocking.
  • Ownership updates stay on the locked file, and certification captures are owner-only.

How: a shared internal writer (control/src/private-file.ts) opens files with an explicit 0600 mode and sets permissions on the open file before writing. The journal stays append-only and the flock ownership stays on the same file; the certification command uses the same order inside the CLI package.

How to verify

Run the new and changed tests, for example control/src/private-file.test.ts, cli/src/commands/certify-permissions.test.ts and the policy, usage and journal store tests. They check file permissions, symlink and FIFO refusal, tightening of an existing journal and cleanup of old temporary files.

Testing and limits
  • The full suite, lint and type checks passed with Bun 1.4.4, and the latest test-only change passed its focused tests. Removing any of the helper's checks, or the journal tightening, makes a test fail.
  • Build, package shape and standalone consumers were checked earlier on Bun and Node and weren't repeated for the last change.
  • Paths have to stay under the calling application's control. No hardware operation, release or deployment is part of this.

Risks

Low. A tool that read these files as another user would now be refused; nothing in the stack does that.


Checklist

  • Docs updated if behavior or structure changed (Rule A: AGENTS.md within budget, README, docs/, versions.yaml)
  • User docs (Rule G): no user-visible change, OR ceralive-docs PR updates English and Spanish, plus ceralive-website PR if a landing claim changed
  • Started from updated main; branch rebased on latest canonical branch (Rule B)
  • Rule D local-scratch reference check passes for tracked files
  • Tests pass; QA evidence attached or linked

@pjeweb pjeweb added the upstream: waits for intent Needs an issue or maintainer agreement before an upstream proposal. label Nov 16, 2026
@pjeweb pjeweb added the parked Parked or held for now; not planned for a train until picked up again. label Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

parked Parked or held for now; not planned for a train until picked up again. upstream: waits for intent Needs an issue or maintainer agreement before an upstream proposal.

Development

Successfully merging this pull request may close these issues.

1 participant